#ifndef TRANSFORMERCONTENT_DATADEFINES_H_3
#define TRANSFORMERCONTENT_DATADEFINES_H_3

#include "vrouteDefines.h"
#include <limits.h>

//class state (instance state )
#define INS_STATE_OK	1
#define INS_STATE_ERROR	2

//protocol towards
#define DUMP_PROTOCOL_PACKET_IN		1
#define DUMP_PROTOCOL_PACKET_OUT	2

//buffer count
#define MEMORY_RECORD_MAX_COUNT		8192
#define MEMORY_RECORD_MIN_COUNT		1024
#define MEMORY_RECORD_DEFOUT_COUNT	2048

//buffer size
#define MEMORY_RECORD_MAX_SIZE		4096+50
#define MEMORY_RECORD_MIN_SIZE		512+50
#define MEMORY_RECORD_DEFOUT_SIZE	1024+50

//log flush interval: 60S
#define LOGGER_FLUSH_INTERVAL_MAX	60000
#define LOGGER_FLUSH_INTERVAL_MIN	3000
#define LOGGER_FLUSH_INTERVAL_DEFAULT LOGGER_FLUSH_INTERVAL_MIN

//port state
#define PORT_STATE_ERROR					0
#define PORT_STATE_REGISTING				1
#define PORT_STATE_REGISTED					2
#define PORT_STATE_LISTEN					3
#define PORT_STATE_ACCEPTING				4
#define PORT_STATE_ACCEPT_FULL				5
#define PORT_STATE_CONNECTING				6
#define PORT_STATE_CONNECTED				7
#define PORT_STATE_STREAM					8
#define PORT_STATE_PACKET					9
#define PORT_STATE_CLOSING					10
#define PORT_STATE_FUNC_QUERY_TARGET		11
#define PORT_STATE_FUNC_TRACERT_TARGET		12
#define PORT_STATE_FUNC_CONSTRUCT_PATH		13
#define PORT_STATE_FUNC_TARGET_REACHABLE	14
#define PORT_STATE_FUNC_PATHSTATE			15
#define PORT_STATE_STACKINFO				16

//message
#define message_type_inner_regist_request								1
#define message_type_inner_regist_response								2
#define message_type_inner_heatBeat										3
#define message_type_inner_functionCall_targetReachable_request			4
#define message_type_inner_functionCall_targetReachable_response		5
#define message_type_inner_functionCall_queryTarget_request				6
#define message_type_inner_functionCall_queryTarget_response			7
#define message_type_inner_functionCall_constructSeq_request			8
#define message_type_inner_FixedPathExist_request						9
#define message_type_inner_FixedPathExist_response						10
#define message_type_inner_functionCall_tracertTarget_request			11
#define message_type_inner_functionCall_tracertTarget_response			12
#define message_type_inner_pathState_request							13
#define message_type_inner_pathState_response							14
#define message_type_inner_port_close									15
#define message_type_inner_getStackInfo									16
#define message_type_inner_functionCall_getFixedPathRequest				17
#define message_type_inner_functionCall_getFixedPathResponse			18
#define message_type_accept-connect										19
#define message_type_out_data_stream									20
#define message_type_out_data_packet									21

// stack info sub message
#define message_type_stackInfo_sub_getLocalAddr							1
#define message_type_stackInfo_sub_setFixedPath							2

// accept-connect sub message 
#define message_type_accept-connect_sub_connect							1
#define message_type_accept-connect_sub_connectAck						2
#define message_type_accept-connect_sub_streamStart						3

//data port sub message
#define message_type_data_stream_sub_dataIn								1
#define message_type_data_stream_sub_portSteate_request					2
#define message_type_data_stream_sub_portSteate_response				3
#define message_type_data_stream_sub_dataACK							4
#define message_type_data_stream_sub_portClose							5

#define message_type_data_packet_sub_dataIn								1

//FIFO name
#define stackFIFORegistName				"/data/data/com.virtualNetwork.core/regist"
#define stackFIFODataOutName			"/data/data/com.vritualNetwork.core/dataOut"

//thread count
#define THREADS_COUNT_MAX			16
#define THREADS_COUNT_MIN			4
#define THREADS_COUNT_DEFAULT		4

//content timer interval
#define CONTENT_TIMER_INTERVAL_MAX		4
#define CONTENT_TIMER_INTERVAL_MIN		1
#define CONTENT_TIMER_INTERVAL_DEFAULT	2

//file name length
#define FILE_NAME_LEN		128

//port count
#define ALLPORT_COUNT_MAX				32
#define ALLPORT_COUNT_MIN				4
#define ALLPORT_COUNT_DEFAULT			8

//regist type
#define REGIST_PORT_TYPE_APPLY			1
#define REGIST_PORT_TYPE_GET			2
#define REGIST_PORT_TYPE_TEST			3

//listen max count
#define LISTEN_COUNT_MAX				10

//response method result
#define RESPONSE_RESULT_DELETE_RECORD	1
#define RESPONSE_RESULT_CHANGE_STATE	2
#define RESPONSE_RESULT_NOACTION		3
#define RESPONSE_RESULT_CREATE_STREAM	4
#define RESPONSE_RESULT_RESET_DEFAULT	5
#define RESPONSE_RESULT_POST_CONITNUE	6
#define	RESPONSE_RESULT_RELEASEBUFFER	7

#define FIXEDPATH_NODE_COUNT_MAX		5
#define FIXEDPATH_NODE_COUNT_MIN		1

#define SYNC_METHOD_RETURN_TIME			3

//accept refused
#define ACCEPT_PORT_REFUSED				2

#define connect_streamPortwait_time		2

typedef struct _connectPeer{
	int localPort;
	int remotePort;
	NodeAddr remoteAddr;
} ConnectPeer;

/// client to stack packet falg values
#define CLIENT_STACK_FLAG_BITS_FIXEDPATH	0X01

#define STREAM_DATA_START_INDEX				12

#define STREAM_BUFFER_SIZE_MAX				128
#define STREAM_BUFFER_SIZE_DEFAULT			32

#define PACKET_BUFFER_SIZE_MAX				128
#define PACKET_BUFFER_SIZE_DEFAULT			32

/// interval to wait avaliable memory buffer, USLEEP
#define TIME_TO_WAIT_AVALIABLE_BUFFER		500000
//

#endif //TRANSFORMERCONTENT_DATADEFINES_H_3
